<template>
  <view class="choose-house-card">
    <view class="choose-house-header">
      <text class="choose-house-title">2、相关材料</text>
    </view>
    <view>
 
      <view v-if="fileUrl && fileUrl.length > 0" class="attachment-list">
          <view 
            v-for="(attachment, index) in fileUrl" 
            :key="index"
            class="attachment-item"
            @click="handleAttachmentClick(attachment)"
          >
            <u-icon name="file-text" size="16" color="#3B75FA"></u-icon>
            <text class="attachment-name">{{ attachment.displayName }}</text>
            <u-icon name="arrow-right" size="14" color="#999"></u-icon>
          </view>
        </view>
        <view v-else class="no-attachment">
          暂无附件
        </view>
   
    </view>
  </view>
</template>

<script>
import warning from '@/static/warning.svg'
import pen from '@/static/pen.svg'
import { uploadSign } from '@/util/update'
import { handleFile } from '@/util/function'
export default {
  name: 'ChooseAHouse',
  props:{
    isVotingInfo:{
      deep:true,
      immediate:true,
      type:Object,
      default:()=>{}
    },
    fileUrl:{
      deep:true,
      immediate:true,
      type:Array,
      default:()=>{}
    }
  },
  watch:{
   fileUrl:{
    deep:true,
    immediate:true,
    handler(newVal){
    
    }
   }
  },
  data() {
    return {
      pen,
      warning,
      isActive: false, // 切换为true/false即可看到不同UI
      signBase64: '',
      signTempimg: ''
    }
  },
  methods: {
    handleAttachmentClick(attachment) {
      // 使用公共文件处理函数
      handleFile(attachment.realUrl, attachment.displayName)
        .then(() => {
         
        })
        .catch((error) => {
          console.error('文件处理失败:', error)
        })
    },

 
 
  }
}
</script>

<style scoped lang="scss">
.choose-house-card {
  background: #fff;
  border-radius: 18rpx;
  padding: 30rpx 20rpx 32rpx 25rpx;
  margin-bottom: 24rpx;
  box-shadow: 0 4rpx 16rpx 0 rgba(0,0,0,0.04);
  margin-top: 20rpx;
}
.choose-house-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12rpx;
}
.choose-house-title {
  font-weight: 600;
  font-size: 30rpx;
  color: #000000;
}
.choose-house-info {
  margin-top:36rpx;
  margin-bottom: 21rpx;
  font-size: 28rpx;
  color: #666;
}
.choose-house-warning {
  display: flex;
  align-items: center;
  color: #F9901B;
  font-size: 28rpx;
}
.choose-house-warning-tip {
  margin-bottom: 32rpx;
}
.choose-house-warning-text {
  margin-left: 8rpx;
}
.choose-house-btn {
  width: 100%;
  border: 2rpx solid $uni-color-primary ;
  border-radius: 12rpx;
  color: $uni-color-primary ;
  font-size: 32rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 88rpx;
 
  margin-top: 18rpx;
}

.choose-house-btn-text {
  font-size: 30rpx;
  font-weight: 400;
  margin-left: 12rpx;
}
.attachment-list {
  margin-top: 20rpx;


}
.no-attachment {
  text-align: center;
  padding: 20rpx 0;
  color: #999;
  font-size: 28rpx;
}
.attachment-item {
  display: flex;
  align-items: center;
  padding: 10rpx 0;
  cursor: pointer;
}
</style>
